| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  |  | 
| 2 |  |  |  |  |  |  | package TeX::Hyphen::czech; | 
| 3 |  |  |  |  |  |  |  | 
| 4 |  |  |  |  |  |  | =head1 NAME | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | TeX::Hyphen::czech -- provides parsing routine for Czech patterns | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | use TeX::Hyphen; | 
| 11 |  |  |  |  |  |  | my $hyp = new TeX::Hyphen 'hyphen.tex', style => 'czech'; | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | # and then follow documentation for TeX::Hyphen | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | This pattern processing happens to be the default. If you need to | 
| 18 |  |  |  |  |  |  | write you own style of parsing the pattern file, you might want to | 
| 19 |  |  |  |  |  |  | start with this file and hack it to suit your needs. There is nothing | 
| 20 |  |  |  |  |  |  | for end users here -- just specify the style parameter in call to new | 
| 21 |  |  |  |  |  |  | TeX::Hyphen. | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | The language style specific modules have to define the following | 
| 24 |  |  |  |  |  |  | functions: | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | =over 4 | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | =item process_patterns | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | This method gets individual lines of the \patterns content. It should | 
| 31 |  |  |  |  |  |  | parse these lines, and fill values in $bothhyphen, $beginhyphen, | 
| 32 |  |  |  |  |  |  | $endhyphen and $hyphen which are being passed to this function as | 
| 33 |  |  |  |  |  |  | parameters following the line. The function should return 0 if end of | 
| 34 |  |  |  |  |  |  | the pattern section (macro) was reached, 1 if the parsing should | 
| 35 |  |  |  |  |  |  | continue. | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | =item process_hyphenation | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | This method gets the lines of the \hyphenation content. It should | 
| 40 |  |  |  |  |  |  | parse these lines and fill values into $exception which is passed as | 
| 41 |  |  |  |  |  |  | second parameter upon call. The function should return 0 if end of the | 
| 42 |  |  |  |  |  |  | exception section (macro) was reached, 1 if the parsing should | 
| 43 |  |  |  |  |  |  | continue. | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | =back | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | Check the TeX::Hyphen::czech source to see the exact form of the | 
| 48 |  |  |  |  |  |  | values inserted into these has structures. | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | Each style module should also define $LEFTMIN and $RIGHTMIN global | 
| 51 |  |  |  |  |  |  | variables, if they have different values than the default 2. The | 
| 52 |  |  |  |  |  |  | values should match the paratemers used to generate the patterns. | 
| 53 |  |  |  |  |  |  | Since various pattern files could be generated with different values | 
| 54 |  |  |  |  |  |  | set, this is just default that can be changed with parameters to the | 
| 55 |  |  |  |  |  |  | TeX::Hyphen constructor. | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | =cut | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | # ###################################################### | 
| 60 |  |  |  |  |  |  | # TeX conversions done for Czech language, eg. \'a, \v r | 
| 61 |  |  |  |  |  |  | # | 
| 62 |  |  |  |  |  |  | my %BACKV = ( 'c' => 'è', 'd' => 'ï', 'e' => 'ì', 'l' => 'µ', | 
| 63 |  |  |  |  |  |  | 'n' => 'ò', 'r' => 'ø', 's' => '¹', 't' => '»', 'z' => '¾', | 
| 64 |  |  |  |  |  |  | 'C' => 'È', 'D' => 'Ï', 'E' => 'Ì', 'L' => '¥', 'N' => 'Ò', | 
| 65 |  |  |  |  |  |  | 'R' => 'Ø', 'S' => '©', 'T' => '«', 'Z' => '®' ); | 
| 66 |  |  |  |  |  |  | my %BACKAP = ( 'a' => 'á', 'e' => 'é', 'i' => 'í', 'l' => 'å', | 
| 67 |  |  |  |  |  |  | 'o' => 'ó', 'u' => 'ú', 'y' => 'ý', 'A' => 'Á', 'E' => 'É', | 
| 68 |  |  |  |  |  |  | 'I' => 'Í', 'L' => 'Å', 'O' => 'Ó', 'U' => 'Ú', 'Y' => 'Ý'); | 
| 69 |  |  |  |  |  |  | sub cstolower { | 
| 70 | 22313 |  |  | 22313 | 0 | 16744 | my $e = shift; | 
| 71 | 22313 |  |  |  |  | 15094 | $e =~ tr/[A-Z]ÁÄÈÏÉÌËÍÅ¥ÒÓÔÕÖØ©«ÚÙÛÜݬ®/[a-z]áäèïéìëíåµòóôõöø¹»úùûüý¼¾/; | 
| 72 | 22313 |  |  |  |  | 24189 | $e; | 
| 73 |  |  |  |  |  |  | } | 
| 74 |  |  |  |  |  |  |  | 
| 75 | 2 |  |  | 2 |  | 8 | use vars qw( $LEFTMIN $RIGHTMIN $VERSION ); | 
|  | 2 |  |  |  |  | 2 |  | 
|  | 2 |  |  |  |  | 941 |  | 
| 76 |  |  |  |  |  |  | $VERSION = 0.121; | 
| 77 |  |  |  |  |  |  | $LEFTMIN = 2; | 
| 78 |  |  |  |  |  |  | $RIGHTMIN = 2; | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | sub process_patterns { | 
| 81 | 22250 |  |  | 22250 | 1 | 18963 | my ($line, $bothhyphen, $beginhyphen, $endhyphen, $hyphen) = @_; | 
| 82 |  |  |  |  |  |  |  | 
| 83 | 22250 | 100 |  |  |  | 28176 | if ($line =~ /\}/) { | 
| 84 | 7 |  |  |  |  | 66 | return 0; | 
| 85 |  |  |  |  |  |  | } | 
| 86 |  |  |  |  |  |  |  | 
| 87 | 22243 |  |  |  |  | 35417 | for (split /\s+/, $line) { | 
| 88 | 22243 | 50 |  |  |  | 24947 | next if $_ eq ''; | 
| 89 |  |  |  |  |  |  |  | 
| 90 | 22243 |  |  |  |  | 12843 | my $begin = 0; | 
| 91 | 22243 |  |  |  |  | 12762 | my $end = 0; | 
| 92 |  |  |  |  |  |  |  | 
| 93 | 22243 | 100 |  |  |  | 25971 | $begin = 1 if s!^\.!!; | 
| 94 | 22243 | 100 |  |  |  | 26105 | $end = 1 if s!\.$!!; | 
| 95 | 22243 |  |  |  |  | 14534 | s!\\v\s+(.)!$BACKV{$1}!g;	# process the \v tag | 
| 96 | 22243 |  |  |  |  | 12916 | s!\\'(.)!$BACKAP{$1}!g;		# process the \' tag | 
| 97 | 22243 |  |  |  |  | 13071 | s!\^\^(..)!chr(hex($1))!eg; | 
|  | 0 |  |  |  |  | 0 |  | 
| 98 |  |  |  |  |  |  | # convert things like ^^fc | 
| 99 | 22243 |  |  |  |  | 82329 | s!(\D)(?=\D)!${1}0!g;		# insert zeroes | 
| 100 | 22243 |  |  |  |  | 31494 | s!^(?=\D)!0!;		# and start with some digit | 
| 101 |  |  |  |  |  |  |  | 
| 102 | 22243 |  |  |  |  | 51496 | ($tag = $_) =~ s!\d!!g;		# get the string | 
| 103 | 22243 |  |  |  |  | 42971 | ($value = $_) =~ s!\D!!g;	# and numbers apart | 
| 104 | 22243 |  |  |  |  | 21892 | $tag = cstolower($tag);		# convert to lowercase | 
| 105 |  |  |  |  |  |  | # (if we knew locales are fine everywhere, | 
| 106 |  |  |  |  |  |  | # we could use them) | 
| 107 |  |  |  |  |  |  |  | 
| 108 | 22243 | 50 | 66 |  |  | 48235 | if ($begin and $end) { | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
| 109 | 0 |  |  |  |  | 0 | $bothhyphen->{$tag} = $value; | 
| 110 |  |  |  |  |  |  | } elsif ($begin) { | 
| 111 | 995 |  |  |  |  | 1883 | $beginhyphen->{$tag} = $value; | 
| 112 |  |  |  |  |  |  | } elsif ($end) { | 
| 113 | 901 |  |  |  |  | 1818 | $endhyphen->{$tag} = $value; | 
| 114 |  |  |  |  |  |  | } else { | 
| 115 | 20347 |  |  |  |  | 40324 | $hyphen->{$tag} = $value; | 
| 116 |  |  |  |  |  |  | } | 
| 117 |  |  |  |  |  |  | } | 
| 118 |  |  |  |  |  |  |  | 
| 119 | 22243 |  |  |  |  | 109852 | 1; | 
| 120 |  |  |  |  |  |  | } | 
| 121 |  |  |  |  |  |  |  | 
| 122 |  |  |  |  |  |  | sub process_hyphenation { | 
| 123 | 75 |  |  | 75 | 1 | 67 | my ($line, $exception) = @_; | 
| 124 |  |  |  |  |  |  |  | 
| 125 | 75 | 100 |  |  |  | 103 | if ($line =~ /\}/) { | 
| 126 | 5 |  |  |  |  | 30 | return 0; | 
| 127 |  |  |  |  |  |  | } | 
| 128 |  |  |  |  |  |  |  | 
| 129 | 70 |  |  |  |  | 61 | local $_ = $line; | 
| 130 |  |  |  |  |  |  |  | 
| 131 | 70 |  |  |  |  | 60 | s!\\v\s+(.)!$BACKV{$+}!g; | 
| 132 | 70 |  |  |  |  | 40 | s!\\'(.)!$BACKAP{$+}!g; | 
| 133 |  |  |  |  |  |  |  | 
| 134 | 70 |  |  |  |  | 105 | ($tag = $_) =~ s!-!!g; | 
| 135 | 70 |  |  |  |  | 76 | $tag = cstolower($tag); | 
| 136 | 70 |  |  |  |  | 368 | ($value = '0' . $_) =~ s!0!g; | 
| 137 | 70 |  |  |  |  | 148 | $value =~ s![^-]-!1!g; | 
| 138 | 70 |  |  |  |  | 102 | $value =~ s![^01]!0!g; | 
| 139 |  |  |  |  |  |  |  | 
| 140 | 70 |  |  |  |  | 111 | $exception->{$tag} = $value; | 
| 141 |  |  |  |  |  |  |  | 
| 142 | 70 |  |  |  |  | 373 | return 1; | 
| 143 |  |  |  |  |  |  | } | 
| 144 |  |  |  |  |  |  |  | 
| 145 |  |  |  |  |  |  | 1; |